package WaiBao;

import java.util.Arrays;

public class LeiYiFan {
    public static void main(String[] args) {
        String[] Tname = {"王格格(班长)", "李大大(副班长)", "小李(学习委员)", "里村支(纪律委员)", "文艺心", "文天祥", "李大钊", "陈独秀", "林则徐", "狄仁杰", "元芳", "展昭",
                "李天龙", "张白虎", "杨涛涛", "倪浩科", "黄飞鸿", "罗吉仁", "叶问", "关琳子", "夏玉洁", "李雨萌", "张琳琳", "蔡健雅", "王大毛", "小野", "喵卡", "曹芬",
                "张碧晨", "雷一凡(生活委员)"};//考生本人: 雷一凡(生活委员)
        int[] Tage = {18, 19, 21, 18, 20, 21, 21, 21, 19, 19, 18, 19, 18, 20, 22, 20, 18, 20, 18, 18, 18, 19, 18, 20, 20, 18, 19, 20, 18,19};//考生年龄：19岁

        double[] luyou1 = {97, 96, 60, 71, 74, 79, 78, 80, 73, 84, 60, 87, 71, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 78, 74, 80, 95};
        double[] luyou2 = {91, 61, 71, 72, 86, 61, 73, 79, 80, 94, 90, 70, 86, 64, 90, 65, 86, 79, 66, 68, 92, 71, 95, 85, 75, 84, 79, 64, 90, 95};
        double[] luyou3 = {74, 78, 74, 83, 71, 61, 78, 80, 84, 60, 63, 80, 75, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 89, 96};

        double shubiao;//代表每个学生的总分
        double shuben;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            shubiao = luyou1[i] + luyou2[i] +luyou3[i];
//            shuben = ( shubiao * 1.0) / 3;
//            System.out.println(Tname[i] + "的总分为:" +  shubiao);
//            System.out.println(Tname[i] + "的平均分为:" + shuben);
//        }

        double chuxue1 = 0,chuxue2 = 0;
        double[] exo = new double[30];
        for (int i = 0; i < 30; i++) {
            chuxue1 = luyou1[i] + luyou2[i] + luyou3[i];
            chuxue2= (chuxue1 * 1.0) / 3;
            exo[i] = chuxue2;
        }

        for (int i = 0; i < exo.length - 1; i++) {
            for (int j = 0; j < exo .length - i - 1; j++) {
                if (exo [j] < exo [j + 1]) {
                    double tep = exo [j];
                    exo[j] = exo[j + 1];
                    exo [j + 1] = tep;
                }
            }
        }
        System.out.println("前十名同学的成绩为:");
        for (int i = 0; i < 10; i++) {
            System.out.println(exo[i]);
        }

        double kexi1 = 0, kexi2 = 0,  kexi3 = 0;//计算每门课的平均分
        double meiyou1 = 0,meiyou2 = 0, meiyou3 = 0;//计算每门课标准差
        double ruguo1 = 0,ruguo2 = 0, ruguo3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < luyou1.length; i++) {
            sum2+=luyou1[i];
        }
        kexi1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+ kexi1);
        double Sum = 0;
        for (int i = 0; i < luyou2.length; i++) {
            Sum+=luyou2[i];
        }
        kexi2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+ kexi2);
        double sum = 0;
        for (int i = 0; i <luyou3.length; i++) {
            sum+=luyou3[i];
        }
        kexi3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+ kexi3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < luyou1.length; i++) {
            c1+= (luyou1[i] -  kexi1)*(luyou1[i] - kexi1);
        }
        meiyou1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+meiyou1);

        for (int i = 0; i < luyou2.length; i++) {
            c2+= (luyou2[i] - kexi2)*(luyou2[i] -  kexi2);
        }
        meiyou2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+meiyou2);

        for (int i = 0; i < luyou3.length; i++) {
            c3+= (luyou3[i] - kexi3)*(luyou3[i] - kexi3);
        }
        meiyou3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+meiyou3);
//////
//        Arrays.sort(luyou1);
//        Arrays.sort(luyou2);
//        Arrays.sort(luyou3);
//        ruguo1 =( luyou1[14]+luyou1[15])*1.0/2;
//        ruguo2 =( luyou2[14]+luyou2[15])*1.0/2;
//        ruguo3 =(luyou3[14]+luyou3[15])*1.0/2;
//        System.out.println("生物化学的中位数为:"+ruguo1);
//        System.out.println("微生物学的中位数为:"+ruguo2);
//        System.out.println("人体组织解剖学的中位数为:"+ruguo3);

    }
}
